package org.deschutter.hibernate;

import javax.persistence.*;
import java.util.Collection;

/**
 * User: Berten De Schutter
 * Date: 01-Oct-2009
 * Time: 13:40:17
 */
@Entity
@Table(catalog = "scimitar", name = "user")
public class User {
    private int id;

    @Id
    @Column(name = "ID")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    private String username;

    @Basic
    @Column(name = "username")
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    private String password;

    @Basic
    @Column(name = "password")
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    private String pnick;

    @Basic
    @Column(name = "pnick")
    public String getPnick() {
        return pnick;
    }

    public void setPnick(String pnick) {
        this.pnick = pnick;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        User user = (User) o;

        if (id != user.id) return false;
        if (password != null ? !password.equals(user.password) : user.password != null) return false;
        if (pnick != null ? !pnick.equals(user.pnick) : user.pnick != null) return false;
        if (username != null ? !username.equals(user.username) : user.username != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + (username != null ? username.hashCode() : 0);
        result = 31 * result + (password != null ? password.hashCode() : 0);
        result = 31 * result + (pnick != null ? pnick.hashCode() : 0);
        return result;
    }

    private Collection<Profile> profilesById;

    @OneToMany(mappedBy = "userByUserId")
    public Collection<Profile> getProfilesById() {
        return profilesById;
    }

    public void setProfilesById(Collection<Profile> profilesById) {
        this.profilesById = profilesById;
    }

    private Collection<ScanUser> scanUsersById;

    @OneToMany(mappedBy = "userByUserId")
    public Collection<ScanUser> getScanUsersById() {
        return scanUsersById;
    }

    public void setScanUsersById(Collection<ScanUser> scanUsersById) {
        this.scanUsersById = scanUsersById;
    }
}
